<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        body{
            background: url(../images/1.jpg);
        }

        li{
            list-style: none;
        }

        .huanfu{
            overflow: hidden;
            margin: 100px auto;
            background-color: #fff;
            width:210px;
            padding-top: 3px;
        }
        .huanfu li{
            float: left;
            margin: 0 1px;
            cursor: pointer;
        }
        .huanfu img{
            width: 100px;
        }


    </style>
</head>
<body>

    <ul class="huanfu">
        <li><img src="../images/1.jpg"></li>
        <li><img src="../images/2.jpg"></li>
    </ul>


    <script>
        var imgs = document.querySelector('.huanfu').querySelectorAll('img');

        for(var i=0;i < imgs.length;i++){
            imgs[i].onclick = function() {
                document.body.style.backgroundImage = 'url('+this.src+')';
            }
        }


    </script>


    
</body>
</html>